package myoa

class ProCompanyController {

    //id for project id
    def create(Long id) {
        [project: Project.read(id)]
    }

    //id for project id
    def save(Long id) {
        def p = new ProCompany(params)

        if (p.save()) {
            flash.message = message(code: 'default.save.success')
            redirect(controller: 'project', action: 'show', id: id, params: [config: true])
        } else {
            flash.message = message(code: 'default.save.failed')
            redirect(action: 'create', id: id)
        }
    }

    def delete(Long id) {
        def p = ProCompany.get(id)
        p.delete()
        flash.message = message(code: 'default.delete.success', args: [p.id])
        redirect(controller: 'project', action: 'show', id: p.project.id, params: [config: true])
    }
}
